'use strict';
let Enumerable = require('linq');
let BaseRender = require('./BaseRender');

/**
 *样式渲染基类
 *
 * @class BaseStyleRender
 * @extends {BaseRender}
 */
class BaseStyleRender extends BaseRender {
    /**
     *Creates an instance of StyleRender.
     * @param {*} data
     * @param {*} style
     * @memberof BaseStyleRender
     */
    constructor(data, style) {
        super(data, style);
        this._itemIndex = -1; // 报表索引
        this._pageNum = 1; // 页码
        this._itemPages = []; // 页码信息
    }

    /**
     *渲染Texts
     *
     * @param {*} tempData
     * @memberof NormalDataStyleRender
     */
    _renderTexts(tempData) {
        Enumerable.from(tempData.texts).forEach(text => {
            if (text.name === 'pageNum') return;
            let value = this._getMasterFieldValue(text, tempData);
            this._renderText(value, {
                left: text.rect.left,
                top: text.isFooter ? tempData.top + 5 : text.rect.top,
                width: text.rect.width,
                height: text.rect.height,
                align: text.align,
                name: text.font.name,
                size: text.font.size,
                valign: text.valign,
            });
        });
    }
}

exports = module.exports = BaseStyleRender;